package littlecyberwar.model;

import java.io.*;
import java.awt.geom.AffineTransform;
import javax.swing.*;
import java.awt.*;

import littlecyberwar.model.*;
import littlecyberwar.tool.*;

/**
 * Title:        LittleCyberWar
 * Description:  A online PBEM or PBC (play be Chat) Miniature utility
 * Copyright:    Copyright (c) 2001
 * Company:      S&S Enterprise
 * @author Milton Soong
 * @version 1.0
 */

 /**
  * An actionID will correspond with a set of fixed prefix & suffix string
  * @parms unitIdIn the universal unitId of the unit in question
  * @parms actionIdIn The handler id that just performed the operation
  * @parms newLocalIn The new location where the unit is ending up
  *
  * IMPORTANT: Note the old location is NOT stored here (it's only used by
  * The InternalCmdQ and it's processed separately there.
  */
public class UnitCommand extends Command implements Serializable {
  Integer unitId;
  Integer actionId;
  AffineTransform location;
  Double distanceMoved;		// the scaled map distance moved for this command

  /**
   * This field is optional. It's only inserted here if it has changed from
   * previous position.
   */
  //Shape newFinalShape;
  public UnitCommand() {
  }
  
  public UnitCommand(
    Integer unitIdIn,
    Integer actionIdIn,
    AffineTransform newLocalIn,
	double distanceIn
    ) {
    unitId = unitIdIn;
    actionId = actionIdIn;
    location = newLocalIn;
    distanceMoved = new Double(distanceIn);
  }
  
  public int getType() {
	return ( _commandType_unit );
  }
  
  public Integer getUnitId() {
    return ( unitId );
  }

  public Integer getActionId() {
    return ( actionId );
  }

  public void setActionId( Integer valIn ) {
    actionId = valIn;
  }

  public AffineTransform getNewLocation() {
    return ( location );
  }

  public void setNewLocation( AffineTransform pos ) {
    location = pos;
  }

  public double getMoveDistance() {  	
	return (distanceMoved.doubleValue());
  }
  
  public String getMoveDistanceString() {  	
	return (MouseHandler.df.format(distanceMoved.doubleValue()));
  }
  
  public String toString() {
    return ( "unitid=" + unitId + ", actionId=" + actionId + ", location=" + location);
  }
}